package com.huiying.mapper;


import com.github.pagehelper.Page;
import com.huiying.annotation.AutoFile;
import com.huiying.entity.dto.WorkDTO;
import com.huiying.entity.dto.WorkPageQueryDTO;
import com.huiying.entity.entity.Work;
import com.huiying.entity.vo.WorkPageVO;
import com.huiying.entity.vo.WorkVO;
import com.huiying.utils.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: lsh
 * @Date: 2024/12/03/22:25
 * @Description: 作品数据访问类
 */
@Mapper
public interface WorkMapper {

    @AutoFile(OperationType.INSERT)
    void insert(Work work);

    @Update("update works set is_authenticated = #{isAuthenticated} where user_id = #{userId}")
    void updateIsAuthenticatedByUserId(@Param("userId") Long userId,
                                       @Param("isAuthenticated") String isAuthenticated);

    @Select("select id from works")
    List<Long> getAllWorkId();

    WorkVO getWorkInfoById(@Param("workId") Long workId,
                           @Param("userId") Long userId);

    Page<WorkPageVO> pageQuery(WorkPageQueryDTO workPageQueryDTO);

    Page<WorkPageVO> pageQueryByIds(@Param("contentIds") List<Long> contentIds);

    @AutoFile(OperationType.UPDATE)
    void updateWork(WorkDTO workDTO);

    @Select("select id, user_id, username, is_authenticated, description, apparatus, location, " +
            "create_time, update_time from works where id = #{wordId}")
    Work getById(Long wordId);

    @Delete("delete from works where id = #{workId}")
    void deleteById(Long wordId);
}
